<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class OrderBase extends Model
{
    protected $appends = ['order_status_desc', 'pay_status_desc', 'shipping_status_desc'];

    public function getOrderStatusDescAttribute()
    {
        // UNCONFIRMED CONFIRMED FINISHED CANCELLED
        $status = $this->attributes['order_status'];
        if ($status == 'UNCONFIRMED')
            return '待确认';
        if ($status == 'CONFIRMED')
            return '已确认';
        if ($status == 'FINISHED')
            return '已完成';
        if ($status == 'CANCELLED')
            return '已取消';
        return $status;
    }
    public function getPayStatusDescAttribute()
    {
        $status = $this->attributes['pay_status'];
        if ($status == 1)
            return '已支付';
        if ($status == 0)
            return '未支付';
        if ($status == 3)
            return '已退款';
        return $status;
    }
    public function getShippingStatusDescAttribute()
    {
        $status = $this->attributes['shipping_status'];
        if ($status == 0)
            return '未发货';
        if ($status == 1)
            return '已发货';
        if ($status == 2)
            return '部分发货';
        return $status;
    }
}
